﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace R.DMS.Data
{
    public class CommonBusiness : BaseBusiness
    {
        CommonDAL dal = new CommonDAL();

        #region 合同

        /// <summary>
        /// 根据条件获取合同信息
        /// </summary>
        /// <param name="name">合同名称</param>
        /// <param name="customerNo">客户编号</param>
        /// <param name="customerName">客户名称 模糊搜索</param>
        /// <param name="status">状态</param>
        public List<ContractEntity> GetContractList(string name, string customerNo, string customerName, string status)
        {
            using (var conn = Connection())
            {
                return dal.GetContractList(conn, name, customerNo, customerName, status);
            }
        }

        /// <summary>
        /// 获取合同详情
        /// </summary>
        /// <param name="id">主键</param>
        public ContractEntity GetContract(int id)
        {
            using (var conn = Connection())
            {
                return dal.GetContract(conn, id);
            }
        }

        /// <summary>
        /// 新增合同信息
        /// </summary>
        public void CreateContract(ContractEntity entity)
        {
            using (var conn = Connection())
            {
                dal.CreateContract(conn, entity);
            }
        }

        /// <summary>
        /// 更新合同信息
        /// </summary>
        public void UpdateContract(ContractEntity entity)
        {
            using (var conn = Connection())
            {
                dal.UpdateContract(conn, entity);
            }
        }

        /// <summary>
        /// 删除合同信息
        /// </summary>
        public void DeleteContract(int id)
        {
            using (var conn = Connection())
            {
                dal.DeleteContract(conn, id);
            }
        }

        #endregion

        #region 项目

        /// <summary>
        /// 根据条件获取项目信息
        /// </summary>
        /// <param name="name">项目名称</param>
        /// <param name="customerNo">客户编号</param>
        /// <param name="customerName">客户名称 模糊搜索</param>
        /// <param name="status">状态</param>
        public List<ProjectEntity> GetProjectList(string name, string customerNo, string customerName, string status)
        {
            using (var conn = Connection())
            {
                return dal.GetProjectList(conn, name, customerNo, customerName, status);
            }
        }

        /// <summary>
        /// 获取项目详情
        /// </summary>
        /// <param name="id">主键</param>
        public ProjectEntity GetProject(int id)
        {
            using (var conn = Connection())
            {
                return dal.GetProject(conn, id);
            }
        }

        /// <summary>
        /// 新增项目信息
        /// </summary>
        public void CreateProject(ProjectEntity entity)
        {
            using (var conn = Connection())
            {
                dal.CreateProject(conn, entity);
            }
        }

        /// <summary>
        /// 更新项目信息
        /// </summary>
        public void UpdateProject(ProjectEntity entity)
        {
            using (var conn = Connection())
            {
                dal.UpdateProject(conn, entity);
            }
        }

        /// <summary>
        /// 删除项目信息
        /// </summary>
        public void DeleteProject(int id)
        {
            using (var conn = Connection())
            {
                dal.DeleteProject(conn, id);
            }
        }

        #endregion

        #region 专利

        /// <summary>
        /// 根据条件获取专利信息
        /// </summary>
        /// <param name="name">专利名称</param>
        /// <param name="type">专利类型</param>
        /// <param name="customerNo">客户编号</param>
        /// <param name="customerName">客户名称 模糊搜索</param>
        /// <param name="status">状态</param>
        /// <param name="year">申请年份</param>
        public List<PatentEntity> GetPatentList(string name, string type, string customerNo, string customerName, string status, string year)
        {
            using (var conn = Connection())
            {
                return dal.GetPatentList(conn, name, type, customerNo, customerName, status, year);
            }
        }

        /// <summary>
        /// 获取专利详情
        /// </summary>
        /// <param name="id">主键</param>
        public PatentEntity GetPatent(int id)
        {
            using (var conn = Connection())
            {
                return dal.GetPatent(conn, id);
            }
        }

        /// <summary>
        /// 新增专利信息
        /// </summary>
        public void CreatePatent(PatentEntity entity)
        {
            using (var conn = Connection())
            {
                dal.CreatePatent(conn, entity);
            }
        }

        /// <summary>
        /// 更新专利信息
        /// </summary>
        public void UpdatePatent(PatentEntity entity)
        {
            using (var conn = Connection())
            {
                dal.UpdatePatent(conn, entity);
            }
        }

        /// <summary>
        /// 删除专利信息
        /// </summary>
        public void DeletePatent(int id)
        {
            using (var conn = Connection())
            {
                dal.DeletePatent(conn, id);
            }
        }

        #endregion

        #region 政策

        /// <summary>
        /// 根据条件获取政策信息
        /// </summary>
        /// <param name="name">政策名称</param>
        /// <param name="year">政策年份</param>
        public List<PolicyEntity> GetPolicyList(string name, string year)
        {
            using (var conn = Connection())
            {
                return dal.GetPolicyList(conn, name, year);
            }
        }

        /// <summary>
        /// 获取政策详情
        /// </summary>
        /// <param name="id">主键</param>
        public PolicyEntity GetPolicy(int id)
        {
            using (var conn = Connection())
            {
                return dal.GetPolicy(conn, id);
            }
        }

        /// <summary>
        /// 新增政策信息
        /// </summary>
        public void CreatePolicy(PolicyEntity entity)
        {
            using (var conn = Connection())
            {
                dal.CreatePolicy(conn, entity);
            }
        }

        /// <summary>
        /// 更新政策信息
        /// </summary>
        public void UpdatePolicy(PolicyEntity entity)
        {
            using (var conn = Connection())
            {
                dal.UpdatePolicy(conn, entity);
            }
        }

        /// <summary>
        /// 删除政策信息
        /// </summary>
        public void DeletePolicy(int id)
        {
            using (var conn = Connection())
            {
                dal.DeletePolicy(conn, id);
            }
        }

        #endregion

        #region 文件

        /// <summary>
        /// 根据条件获取文件信息
        /// </summary>
        /// <param name="name">文件名称</param>
        /// <param name="relatedId">文件关联外键</param>
        /// <param name="type">文件类型</param>
        public List<UploadFilesEntity> GetFileList(string name, string relatedId, string type)
        {
            using (var conn = Connection())
            {
                return dal.GetFileList(conn, name, relatedId, type);
            }
        }

        /// <summary>
        /// 获取文件详情
        /// </summary>
        /// <param name="id">主键</param>
        public UploadFilesEntity GetFile(int id)
        {
            using (var conn = Connection())
            {
                return dal.GetFile(conn, id);
            }
        }

        /// <summary>
        /// 新增文件信息
        /// </summary>
        public void CreateFile(UploadFilesEntity entity)
        {
            using (var conn = Connection())
            {
                dal.CreateFile(conn, entity);
            }
        }

        /// <summary>
        /// 更新文件信息
        /// </summary>
        public void UpdateFile(UploadFilesEntity entity)
        {
            using (var conn = Connection())
            {
                dal.UpdateFile(conn, entity);
            }
        }

        /// <summary>
        /// 删除文件信息
        /// </summary>
        public void DeleteFile(int id)
        {
            using (var conn = Connection())
            {
                dal.DeleteFile(conn, id);
            }
        }

        #endregion

    }
}
